<template>
  <div class="app-container">
    <el-row :gutter="20" type="flex">
      <el-col style="width: 300px;">
        <pointList v-on:handlePointClick="handlePointClick"></pointList>
      </el-col>
      <el-col>
        <el-card class="box-card" :style="{height: tabHt+'px'}">
          <el-form ref="form" :model="form" :rules="rules" label-width="80px" style="width: 800px;">
            <el-row>
              <el-col :span="24">
                <el-form-item label="下载报文" prop="bw">
                  <el-input type="textarea" :rows="3" v-model="form.bw" placeholder="请输入下载报文" />
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item>
                  <el-button type="primary" @click="downTxt" >下载调试</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="信息记录" >
                  <el-input type="textarea" :rows="10" v-model="msg" readonly  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-card>
      </el-col>
    </el-row>

  </div>
</template>

<script>
  import pointList from "@/views/components/pointTreeList";

export default {
  name: "DutyRemoteCall",
  components: { pointList },
  data() {
    return {
      msg:'',
      // 表单参数
      form: {
        bw:null,
      },
      // 表单校验
      rules: {
        bw: [
          { required: true, message: "报文不能为空", trigger: "blur" }
        ],
      }
    };
  },
  computed: {
    tabHt(){
      return this.$store.state.app.tableHeight.pointHt
    }
  },
  created() {
  },
  methods: {
    downTxt(){
      this.$refs["form"].validate(valid => {
        if (valid) {
          let nowDate = new Date();
          let byear = nowDate.getFullYear();
          let bmonth = (nowDate.getMonth() + 1 + '').padStart(2, '0');
          let bday = (nowDate.getDate()+ '').padStart(2, '0');
          let bhours = (nowDate.getHours()+ '').padStart(2, '0');
          let seconds = (nowDate.getSeconds()+ '').padStart(2, '0');
          let minutes = (nowDate.getMinutes()+ '').padStart(2, '0');
          let sj = `${byear}-${bmonth}-${bday} ${bhours}:${seconds}:${minutes}`
          this.msg = sj + '【发送】' + this.form.bw +'\n' + this.msg;

        }
      });

    },
    handlePointClick(obj){

    },
  }
};
</script>
